<?php
require_once("config.php");
require_once("inc.php");
if (!session_start()) {session_start();}
header("Content-type: text/html; charset=utf-8");

if (isset($_GET['tj'])) {
    $username = isset($_GET['user']) ? trim($_GET['user']) : '';
    if (empty($username)) {
        die('ERROR:illegal username');
    }
    $_SESSION['username'] = $username;
    echo '<h3>前往Flickr，登录您的账号予以授权...</h3>';
    echo '<script type="text/javascript">location.href="/flickrget/auth.php";</script>';
} elseif (isset($_GET['frob'])) {
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$_SESSION['username']?>的原始照片URL</title>
    <script type="text/javascript">
    function clearTip() {
        document.getElementById("tip").innerText = '';
    }    
    </script>
<style type="text/css">
</style>
</head>
<body>
<h1><?=$_SESSION['username']?>的原始照片URL</h1>
<div id='tip'>正在获取中，请耐心等待...</div>
<iframe width="780" height="640" frameborder="0" src="/flickrget/download.php?sid=<?=$_GET['frob']?>&user=<?=$_SESSION['username']?>"></iframe>
</body>
</html>

<?php

} else {
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>获取所有原始照片url</title>
<style type="text/css">
</style>
</head>
<body>
<h1>Flickr昵称</h1>
<form action="" method="get">
<input type="text" name="user" />
<input type="submit" name="tj" value="获取原始照片urls" />
</form>
</body>
</html>


<?php
}

?>
